package git.bankview.wl.auth;

import laya.semi.process.*;

import git.bankview.wl.bean.LogonBean;
import git.bankview.sl.report.ReportCommon;
import git.bankview.wl.auth.UserAuth;

import org.apache.log4j.Logger;

public class UserTransValidateActivity
	implements IGenericClassActivity
{
	private static Logger log = Logger.getLogger(UserTransValidateActivity.class);
   
	public void execute(IProcessContext oCtx)
		throws Exception
	{
		// logon-name:transid:method-array
		String[] vArg = oCtx.getActivityParameter().split(":");
		LogonBean user = (LogonBean)oCtx.getField(vArg[0]);
		Object tTransid = 
			('(' == vArg[1].charAt(0) && ')' == vArg[1].charAt(vArg[1].length() - 1) ? 
				vArg[1].substring(1, vArg[1].length() - 1) : oCtx.getField(vArg[1]));
		String[] vTransid = (tTransid.getClass().isArray() ? 
			(String[])tTransid : new String[] {(String)tTransid});
		
		String[] vMethod = vArg[2].split(",");
		
		for (int i = 0; i < vTransid.length; ++i)
		{
			for (int j = 0; j < vMethod.length; ++j)
			{
				UserAuth.validate(user, vTransid[i], Integer.parseInt(vMethod[j]));
			}
		}
	}
}
